#include<iostream>
#include<ctime>
using namespace std;

class Entity
{
private:
	int attackNum;
	int attackRoll;
	int attackDamage;
	int magicNum;
	int magicRoll;
	int magicDamage;
	bool crit;
	int armorNum;
	int armorRoll;
	int armorLevel;
	int resistNum;
	int resistRoll;
	int resistLevel;
	int hp;


	//TJD
	int entityAt;
	int move;
	int entityRange;
	//int tick;
	int entityTeam;
public:
	Entity(int attNum, int magNum, int armNum, int resNum, int health, int range, int playerAt, int team);
	void minusHp(int damage);
	int getHp();
	int getAttackDamage();
	int getArmorLevel();
	int getMagicDamage();
	int getResistLevel();
	void attack();
	void defend();
	void magicAttack();
	void resist();

	//TJD
	void entityMove();
	int getEntityAt();
	int getMove();
	void setEntityAt(int at);
	int getRange();
	int getTeam();
};

Entity::Entity(int attNum, int magNum, int armNum, int resNum, int health, int range, int playerAt, int team)
{
	attackNum = attNum;
	attackRoll = 0;
	attackDamage = 0;
	magicNum = magNum;
	magicRoll = 0;
	magicDamage = 0;
	crit = false;
	armorNum = armNum;
	armorRoll = 0;
	armorLevel = 0;
	resistNum = resNum;
	resistRoll = 0;
	resistLevel = 0;
	hp = health;
	entityAt = playerAt;
	entityRange = range;
	entityTeam = team;
}
int Entity::getTeam()
{
	return entityTeam;
}
int Entity::getRange()
{
	return entityRange;
}
void Entity::setEntityAt(int at)
{
	entityAt = at;
}

int Entity::getMove()
{
	cout << "Enter move: "; 
	cin >> move;
	return move;
}

int Entity::getEntityAt()
{
	return entityAt;
}

int Entity::getHp()
{
	return hp;
}

void Entity::attack()
{
	attackDamage = 0;
	crit = false;
	for (int x = 0; x < attackNum; x++)
		{
			attackRoll = rand() % 10 + 1;
			cout << "Attack Roll: " << attackRoll << endl;
			if (attackRoll >= 4)
			{
				if (attackRoll == 10)
					crit = true;
				attackDamage++;
			}
		}
	if (crit)
		attackDamage++;
	cout << "Attack Damage: " << attackDamage << endl;
}

void Entity::defend()
{
	armorLevel = 0;
	for (int x = 0; x < armorNum; x++)
	{
		armorRoll = rand() % 10 + 1;
		cout << "Armor Roll: " << armorRoll << endl;
		if (armorRoll >= 4)
			{
				armorLevel++;
			}
	}
	cout << "Armor Level: " << armorLevel << endl;
}

void Entity::minusHp(int damage)
{
	hp = hp - damage;
	if (hp < 0)
		hp = 0;
}

int Entity::getAttackDamage()
{
	return attackDamage;
}

int Entity::getArmorLevel()
{
	return armorLevel;
}

void Entity::magicAttack()
{
	magicDamage = 0;
	crit = false;
	for (int x = 0; x < magicNum; x++)
	{
		magicRoll = rand() % 10 + 1;
		cout << "Magic Roll: " << magicRoll << endl;
		if (magicRoll >= 4)
		{
			if (magicRoll == 10)
				crit = true;
			magicDamage++;
		}
	}
	if (crit)
		magicDamage++;
	cout << "Magic Damage: " << magicDamage << endl;
}

void Entity::resist()
{
	resistLevel = 0;
	for (int x = 0; x < resistNum; x++)
	{
		resistRoll = rand() % 10 + 1;
		cout << "Resist Roll: " << resistRoll << endl;
		if (resistRoll >= 4)
		{
			resistLevel++;
		}
	}
	cout << "Resist Level: " << resistLevel << endl;
}

int Entity::getMagicDamage()
{
	return magicDamage;
}

int Entity::getResistLevel()
{
	return resistLevel;
}
